package com.example.yang_android_app_eighth;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.MediaController;
import android.widget.VideoView;

import android.os.Bundle;
import android.widget.MediaController;

import java.io.File;

public class play extends AppCompatActivity {
    MediaController mController;
    VideoView videoView;
    @Override

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_play);
        mController=new MediaController(this);
        videoView=findViewById(R.id.video);
        Intent getIntent = getIntent();
        System.out.println("????");
        String url = getIntent.getStringExtra("url");
        File video =new File("/storage/emulated/0/"+url);
        System.out.println(video.getAbsolutePath());
        if(video.exists())
        {
            System.out.println("zhaodoale ");
            videoView.setVideoPath(video.getAbsolutePath());
            videoView.setMediaController(mController);
            mController.setMediaPlayer(videoView);
            videoView.requestFocus();
        }
    }
}
